<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('福利类型')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <input type="hidden" id="ComPidorDepTid" name="ComPidorDepTid">
                    <div class="select-list">
                        <ul>
                            <li>
                                代码：<input type="text" name="code"/>
                            </li>
                            <li>
                                名称：<input type="text" name="title"/>
                            </li>
                            <li>
                                项目类型：
                                <select name="xType"  th:with="type=${@dict.getType('CCD_BTType')}">
                                    <option value="0">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary single disabled" onclick="edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: hr-help-js"/>

<script th:inline="javascript">
    var prefix = ctx + "welfare/region/welfareType";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryData();
    });

    function queryData() {
        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            modalName: "福利类型",
            columns: [{
                checkbox: true
            },
                {
                    field: 'code',
                    title: '代码'
                },
                {
                    field: 'title',
                    title: '名称'
                },
                {
                    field: 'xTypeName',
                    title: '*项目类型'
                },
                {
                    field: 'xorder',
                    title: '排序'
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '？锁定',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return islockState(row, "福利类型");
                    }
                }]
        };
        $.table.init(options);
    }


    /* 锁定 */
    function enable(id) {
        console.log(id);
        $.modal.confirm("确认要锁定？", function () {
            $.operate.post(prefix + "/changeLock", {"id": id, "islock": 1});
        })
    }

    function edit(){
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        console.log(row);
        if(row[0].islock == 1){
            $.modal.alertWarning("该项已锁定!");
        }
    }

</script>
</body>
</html>